def prime(a):
  p = 1
  if a < 2:
    p = 0
  else:
    for i in range(2, a//2+1):
      if a % i == 0:
        p = 0
  return p

a = input()
a = a.replace(' ', '').replace('one', '1')
a = a.replace('two', '2')
a = a.replace('three', '3')
a = a.replace('four', '4')
a = a.replace('five', '5')
a = a.replace('six', '6')
a = a.replace('seven', '7')
a = a.replace('eigth', '8')
a = a.replace('nine', '9')
a = a.replace('zero', '0')

if len(a) == 3 and a[0] in '0123456789' and a[1] in '0123456789' and \
   a[2] in '0123456789':
  a = int(a)
  b = a
  c = a
  if prime(a) == 1:
    print(a)
  else:
    while True:
      b = b - 1
      c = c + 1
      if prime(b) == 1:
        print(b)
        break
      if prime(c) == 1:
        print(c)
        break
else:
  print('Wrong input')
